package cn.ppool.xmlmapper.builder.parse.parsetest;

import lombok.Data;
import lombok.Getter;
import lombok.ToString;

import java.util.ArrayList;
import java.util.List;

@Data
public class ConditionModel {

    public ConditionModel() {
        brackets = false;
        mathList = new ArrayList<>();
    }


    public boolean brackets;            // 是否括号表达式
    @Getter
    public List<BitType> mathList;       // 表达式列表

    public boolean getBrackets() {
        return brackets;
    }

    public ConditionModel setIsBrackets() {
        if (brackets) throw new RuntimeException("代码逻辑错误，应该一个左括号开一个function");
        brackets = true;
        return this;
    }

    public ConditionModel writeWord(String text, TYPE_ENUM type) {
        mathList.add(new BitType(type, text));
        return this;
    }

    public ConditionModel writeWord(TestStringRunTime.TestWordVO vo) {
        mathList.add(new BitType(vo.getType(), vo.getWord()));
        return this;
    }

    public ConditionModel writeOperate(String opa) {
        mathList.add(new BitType(TYPE_ENUM.operate, opa));
        return this;
    }

    public ConditionModel writeModel(ConditionModel opa) {
        mathList.add(new BitType(opa));
        return this;
    }


    public ConditionModel write(TestStringRunTime.TestWordVO vo) {
        mathList.add(new BitType(vo.getType(), vo.getWord()));
        return this;
    }

    public ConditionModel write(ConditionModel vo) {
        mathList.add(new BitType(vo));
        return this;
    }



}